<template>
<view class="">
	<phone-directory :phones="phones" @paramClick="paramClick"></phone-directory>

	<s-popup custom-class="demo-popup" position="bottom" v-model="visible">	  
	  	<view class="tel" @click="searchHouse">他的房源</view>		
		<view class="tel" @click="tel">联系他</view>	  		  
	</s-popup>
</view>
</template>

<script>
    var _self;
	import sPopup from '@/components/s-popup/index.vue'
	import phoneDirectory from '@/components/phones-address/phone-directory.vue'
	export default{
		data(){
			return{
				phones:{},
				visible: false,
				person_id:0,
			}
		},
		mounted() {
			
		},
		onLoad(){
			_self = this
			this.checkLogin()
			this.getphones()	
		},
		
		methods:{
			getphones(){
				uni.request({
					url: this.websiteUrl+'/api.php/friends/connections',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded',						
					},
					data: {token:uni.getStorageSync('token')},
					success:function(res){
					   
						_self.phones = res.data.data
						
					},
					
				});
			},
			paramClick(e){				
				this.visible = true
				this.person_id = e.id
										
			},
			searchHouse(){
				uni.request({
					url: this.websiteUrl+'/api.php/Friends/detail',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded',						
					},
					data: {id:this.person_id},
					success: res => {
						if(res.data.code == 1){
							var agent_id = res.data.data.agent_id
							uni.navigateTo({															
								url:"../index/her?user_id="+agent_id
							})
						}
					},
					
				});
				
			},
			tel(){
				uni.request({
					url: this.websiteUrl+'/api.php/Friends/detail',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded',						
					},
					data: {id:this.person_id},
					success: res => {
						if(res.data.code == 1){
							var mobile = res.data.data.mobile
							uni.makePhoneCall({
								phoneNumber:mobile
							})
						}
					},
					
				});
			}
		},
		
		components:{
			phoneDirectory,
			sPopup
		}
	}
</script>

<style>
	.tel{
		width:100%;
		height:112rpx;
		line-height:112rpx;
		text-align:center;
		font-size:30rpx;
		border-top:#E5E5E5 1rpx solid;
	}
</style>
